package com.zh.zhbootcommon.config.mq;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 描述: RabbitMQ
 *
 * @author: yanglin
 * @Date: 2021-11-16-16:29
 * @Version: 1.0
 */
@Configuration
public class QueueConfig {

    @Bean
    public DirectExchange defaultExchange() {
        return new DirectExchange("zh-mq-default");
    }

    @Bean
    public DirectExchange notifyMsgDirectExchange() {
        return new DirectExchange("zh-mq-notify");
    }

    @Bean
    public Queue notifyMsgQueue() {
        return new Queue("zh-mq-queue", true);
    }


    @Bean
    public Binding notifyMsgQueueBinding() {
        return BindingBuilder
                .bind(notifyMsgQueue())
                .to(notifyMsgDirectExchange())
                .with("zh-mq-routing");
    }
}
